package better;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;

public class Test02PrerareStatement {
    public static void main(String[] args) {
        Connection connection = null;
        PreparedStatement ps = null;
        ResultSet resultSet = null;
        String sql = null;

        try {
            connection = JDBCUtils.getConnection();
            sql = "SELECT * FROM emp WHERE EMPNO = ?";
            ps = connection.prepareStatement(sql);
            ps.setInt(1, 7369);

            resultSet = ps.executeQuery();

            while (resultSet.next()) {
                System.out.println(resultSet.getInt("empno") + " " + resultSet.getString("ename") + " "
                        + resultSet.getDouble("sal"));
            }

        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            JDBCUtils.close(connection, ps, resultSet);
        }
    }
}
